package queue;

import java.io.Serializable;
import java.util.RandomAccess;

/**
 * 数组实现队列
 */
public class MyArrayQueqe {
    public static void main(String[] args) {

    }
     class ArrayQueue<T> implements RandomAccess,Cloneable, Serializable {
        private int maxSize;
        private int front;
        private int rear;
        private Object[] arr;
        private  final Object[] EMPTY_ELEMENTDATA={};
        public ArrayQueue(){
            maxSize = 0;
            front = -1;
            rear = -1;
            arr =  EMPTY_ELEMENTDATA;
        }
         public ArrayQueue(int initialCapacity) {
            maxSize = initialCapacity;
            arr = new Object[initialCapacity];
             front = -1;
             rear = -1;
         }
         public boolean isFull(){
            return rear == maxSize-1;
         }
         public boolean isEmpty(){
            return rear==front;
         }
         public void addQueue(T n){
            if (isFull())
                return ;
            rear++;
            arr[rear] = n;
         }
         public T pop() throws Exception{
            if (isEmpty())
                throw new Exception("null");
            front++;
            return (T) arr[front];
         }
         public void show(){
             for (int i = 0; i < arr.length; i++) {
                 System.out.println(arr[i]);
             }
         }
         public T getFirst(){
            return (T) arr[front+1];
         }



    }
}
